<!DOCTYPE html>
<html class="signin no-js" lang="zh_CN" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
    <title th:text="${order.siteName}+' - 正在返回'"></title>
    <meta name="keywords" th:content="${config.keywords}">
    <meta name="description" th:content="${config.decText}">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="/static/css/register.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <link href="/static/layer/mobile/need/layer.css" rel="stylesheet">
    <script src="/static/js/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="/static/layer/layer.js"></script>
    <style>
        .login-bg {
            background: url(/static/images/bg.png) no-repeat center;
            background-size: cover;
            overflow: hidden;
            text-align: center;
        }
    </style>
</head>
<body class="login-bg">
<h3 style="font-size: 40px;color: greenyellow;padding-top: 80px;" id="efewdew">正在验证订单,请稍后...</h3><br>
</body>
<script th:inline="javascript">

    var num = 0;

    window.onload = loadmsg();

    // 检查是否支付完成
    function loadmsg() {
        $.ajax({
            type: "POST",
            dataType: "json",
            url: "/payment/order_state2",
            timeout: 8000,
            data: {oid: '[(${order.id})]', "times": new Date().getDate()}, //post数据
            success: function (data, textStatus) {
                if (data.status == 2) {
                    $("#efewdew").html('支付成功,正在返回商户...');
                    layer.msg('支付成功，正在跳转中...', {icon: 16, shade: 0.01, time: 15000});
                    window.location.href = data.backurl;
                } else {
                    if (num < 20) {
                        setTimeout("loadmsg()", 1500);
                        num++;
                    } else {
                        $("#efewdew").html('支付失败,正在返回商户...');
                        layer.msg('支付失败，正在返回...', {icon: 16, shade: 0.01, time: 15000});
                        window.location.href = data.backurl;
                    }
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                if (textStatus == "timeout") {
                    setTimeout("loadmsg()", 1500);
                } else { //异常
                    setTimeout("loadmsg()", 3000);
                }
            }
        });
    }

</script>
</html>

